package com.sun.metric;

import io.prometheus.client.Collector;
import io.prometheus.client.GaugeMetricFamily;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Service
public class DataMonitorExports extends Collector {

    /**
     * CounterMetricFamily：自定义计数器收集器
     * GaugeMetricFamily：自定义仪表盘收集器
     * SummaryMetricFamily：自定义摘要收集器
     */
    @Override
    public List<MetricFamilySamples> collect() {
        List<MetricFamilySamples> mfs = new ArrayList<>();
        GaugeMetricFamily monitorInfo = new GaugeMetricFamily(
                "monitor_source_data",
                "Monitor Source Data",
                Arrays.asList("DataModuleType", "Type"));
        monitorInfo.addMetric(Arrays.asList("Demo", "totalCount"), 100);
        monitorInfo.addMetric(Arrays.asList("Demo", "successCount"), 99);
        monitorInfo.addMetric(Arrays.asList("Demo", "failCount"), 1);
        mfs.add(monitorInfo);
        return mfs;
    }

}
